package com.meilingcloud.activiti.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.activiti.domain.ActWfFormData;
import com.meilingcloud.activiti.mapper.ActWfFormDataMapper;
import com.meilingcloud.activiti.service.IActWfFormDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 动态表单 Service业务层处理
 *
 * @author chenl
 * @date 2021-01-28
 */
@Service
public class ActWfFormDataServiceImpl extends ServiceImpl<ActWfFormDataMapper, ActWfFormData> implements IActWfFormDataService {

    @Override
    public List<ActWfFormData> queryList(ActWfFormData actWfFormdata) {
        LambdaQueryWrapper<ActWfFormData> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(actWfFormdata.getBusinessKey())) {
            lqw.eq(ActWfFormData::getBusinessKey, actWfFormdata.getBusinessKey());
        }
        if (StringUtils.isNotBlank(actWfFormdata.getFormKey())) {
            lqw.eq(ActWfFormData::getFormKey, actWfFormdata.getFormKey());
        }
        if (StringUtils.isNotBlank(actWfFormdata.getFormData())) {
            lqw.eq(ActWfFormData::getFormData, actWfFormdata.getFormData());
        }
        if (StringUtils.isNotBlank(actWfFormdata.getFormDesc())) {
            lqw.eq(ActWfFormData::getFormDesc, actWfFormdata.getFormDesc());
        }
        if (StringUtils.isNotBlank(actWfFormdata.getTaskNodeName())) {
            lqw.like(ActWfFormData::getTaskNodeName, actWfFormdata.getTaskNodeName());
        }
        return this.list(lqw);
    }

    @Override
    public List<ActWfFormData> queryByBusinessKey(String businessKey) {
        return baseMapper.selectList(new QueryWrapper<ActWfFormData>().eq("business_key", businessKey));
    }
}
